<?php
/**
 * @author ykm 2016-01-25
 * @describe 电子面单物流公司请求
 */

class ome_event_trigger_logistics_electron {
    private $logIdentifier = '';

    #发货单物流回传(只回传主单)
    public function delivery($deliveryId){
        $delivery = app::get('ome')->model('delivery')->getList('*', array('delivery_id' => $deliveryId));
        $deliveryData = $delivery[0];
        $corp = app::get('ome')->model('dly_corp')->dump(array('corp_id'=>$deliveryData['logi_id']), 'tmpl_type,channel_id');
        if($corp['tmpl_type'] != 'electron') {
            return true;
        }
        $channel = app::get('logisticsmanager')->model('channel')->dump(array('channel_id'=>$corp['channel_id']));
        $shop = app::get('logisticsmanager')->model('channel_extend')->dump(array('channel_id'=>$corp['channel_id']),'province,city,area,address_detail,seller_id,default_sender,mobile,tel,zip');
        $sdf = kernel::single('ome_event_trigger_logistics_data_electron_router')
            ->setChannel($channel)
            ->getDeliverySdf($deliveryData, $shop);
        if($sdf) {
            return kernel::single('erpapi_router_request')->set('logistics', $channel['channel_id'])->electron_delivery($sdf);
        }
        return true;
    }

    
}